{extend name="public:index"/}
{block name="title"}{:sysconf('title')}{/block}
{block name="content"}
<section class="daifubox">
	<div class="top">
		<p class="p1"></p>
		<p class="p2">我的订单</p>
		<p class="p3"></p>
	</div>
	<div class="daifnav">
		<ul>
			<li class="canli">全部</li>
			<li>待付款</li>
			<li>待发货</li>
			<li>待收货</li>
			<li>已完成</li>
		</ul>
	</div>
	<div style="height:4rem;"></div>
	<div class="ncdfbox">
		<div class="dfbox">
			{if condition="$orderAll"}
			{foreach name="orderAll" item="all"}
			<ul class="shopul">
				<li>
					<a href="{:url('Order/show',['orderId'=>$all['id']])}"><div class="daiff">订单编号：{$all['order_no']}</div></a>
					{eq name="all.status" value="0"}
					<div class="shacc" data-id="{$all['id']}"><img style="width:0.8rem" src="__INDEX__/images/del.png" alt=""></div>
					{/eq}
				</li>
				{foreach name="all.goods" item="order"}
				<li>
					<div class="tabb">
						<div class="left">
							<a href="{:url('Goods/show',['id'=>$order['goods_id']])}"><img src="{$order['goods_img_url']}" alt=""></a>
						</div>
						<div class="right">
							<b><a href="{:url('Goods/show',['id'=>$order['goods_id']])}">{$order['goods_title']}</a></b>
							<p>￥{$order['goods_sell_price']} <em>x {$order['goods_count']}</em></p>
						</div>
					</div>
				</li>
				{/foreach}
				<li>
					<div class="zhufff">
					{switch name="all.status"}
						{case value="0"}<a href="{:url('Pay/index')}?orderNo={$all['order_no']}">去支付</a>{/case}
						{case value="1"}<a href="javascript:;">等待发货</a>{/case}
						{case value="2"}
							<p style="padding:0 0.5rem;padding-bottom:0.5rem;color:#666;margin-bottom:0.5rem;
						border-bottom: 1px solid #eee;">快递公司 : {$all['send_title']}   快递单号 : {$all['send_no']} </p>

						<a href="javascript:;" class="qrsh" data-id="{$all['id']}">确认收货</a>{/case}
						{case value="5"}<a href="{:url('Order/show',['orderId'=>$all['id']])}">订单详情</a>{/case}
					{/switch}
					<a class="youfeif" href="javascript:;">邮费 {$all['cost']}  总计 {$all['cost']+$all['sum']}</a>
					</div>
				</li>
			</ul>
			{/foreach}
			{else/}
			<div class="nofind"><img src="__INDEX__/images/nodd.png" alt=""><p>暂时没有订单</p></div>
			{/if}
		</div>
		<div class="dfbox">
			{if condition="$order1"}
			{foreach name="$order1" item="item"}
			<ul class="shopul">
				<li>
					<a href="{:url('Order/show',['orderId'=>$item['id']])}"><div class="daiff">订单编号：{$item['order_no']}</div></a>
					<div class="shacc" data-id="{$item['id']}"><img style="width:0.8rem" src="__INDEX__/images/del.png" alt=""></div>
				</li>
				{foreach name="$item.goods" item="goods"}
				<li>
					<div class="tabb">
						<div class="left">
							<a href="{:url('Goods/show',['id'=>$goods['goods_id']])}"><img src="{$goods['goods_img_url']}" alt=""></a>
						</div>
						<div class="right">
							<b><a href="{:url('Goods/show',['id'=>$goods['goods_id']])}">{$goods['goods_title']}</a></b>
							<p>￥{$goods['goods_sell_price']} <em>x {$goods['goods_count']}</em></p>
						</div>
					</div>
				</li>
				{/foreach}
				<li>
					<div class="zhufff"><a href="{:url('Pay/index')}?orderNo={$item['order_no']}">去支付</a>
						<a class="youfeif" href="javascript:;">邮费 {$item['cost']} 总计 {$item['cost']+$item['sum']}</a>
					</div>
				</li>
			</ul>
			{/foreach}
			{else/}
			<div class="nofind"><img src="__INDEX__/images/nodd.png" alt=""><p>暂时没有订单</p></div>
			{/if}
		</div>
		<div class="dfbox">
			{if condition="$order2"}
			{foreach name="$order2" item="item"}
			<ul class="shopul">
				<li>
					<a href="{:url('Order/show',['orderId'=>$item['id']])}"><div class="daiff">订单编号：{$item['order_no']}</div></a>
					<!--<div class="shacc"><img style="width:0.8rem" src="__INDEX__/images/del.png" alt=""></div>-->
				</li>
				{foreach name="$item.goods" item="goods"}
				<li>
					<div class="tabb">
						<div class="left">
							<a href="{:url('Goods/show',['id'=>$goods['goods_id']])}"><img src="{$goods['goods_img_url']}" alt=""></a>
						</div>
						<div class="right">
							<b><a href="{:url('Goods/show',['id'=>$goods['goods_id']])}">{$goods['goods_title']}</a></b>
							<p>￥{$goods['goods_sell_price']} <em>x {$goods['goods_count']}</em></p>
						</div>
					</div>
				</li>
				{/foreach}
				<li>
					<div class="zhufff"><a href="javascript:;">等待发货</a>
					<a class="youfeif" href="javascript:;">邮费 {$item['cost']} 总计 {$item['cost']+$item['sum']}</a></div>
				</li>
			</ul>
			{/foreach}
			{else/}
			<div class="nofind"><img src="__INDEX__/images/nodd.png" alt=""><p>暂时没有订单</p></div>
			{/if}
		</div>
		<div class="dfbox">
			{if condition="$order3"}
			{foreach name="$order3" item="item"}
			<ul class="shopul">
				<li>
					<a href="{:url('Order/show',['orderId'=>$item['id']])}"><div class="daiff">订单编号：{$item['order_no']}</div></a>
					<!--<div class="shacc"><img style="width:0.8rem" src="__INDEX__/images/del.png" alt=""></div>-->
				</li>
				{foreach name="$item.goods" item="goods"}
				<li>
					<div class="tabb">
						<div class="left">
							<a href="{:url('Goods/show',['id'=>$goods['goods_id']])}"><img src="{$goods['goods_img_url']}" alt=""></a>
						</div>
						<div class="right">
							<b><a href="{:url('Goods/show',['id'=>$goods['goods_id']])}">{$goods['goods_title']}</a></b>
							<p>￥{$goods['goods_sell_price']} <em>x {$goods['goods_count']}</em></p>
						</div>
					</div>
				</li>
				{/foreach}
				<li>
					<div class="zhufff">
						<p style="padding:0 0.5rem;padding-bottom:0.5rem;color:#666;margin-bottom:0.5rem;
						border-bottom: 1px solid #eee;">快递公司 : {$item['send_title']}   快递单号 : {$item['send_no']} </p>
						<a href="javascript:;" class="qrsh" data-id="{$item['id']}">确认收货</a>
					<a class="youfeif" href="javascript:;">邮费 {$item['cost']} 总计 {$item['cost']+$item['sum']}</a></div>
				</li>
			</ul>
			{/foreach}
			{else/}
			<div class="nofind"><img src="__INDEX__/images/nodd.png" alt=""><p>暂时没有订单</p></div>
			{/if}
		</div>
		<div class="dfbox">
			{if condition="$order4"}
			{foreach name="$order4" item="item"}
			<ul class="shopul">
				<li>
					<a href="{:url('Order/show',['orderId'=>$item['id']])}"><div class="daiff">订单编号：{$item['order_no']}</div></a>
					<div class="shacc" data-id="{$item['id']}"><img style="width:0.8rem" src="__INDEX__/images/del.png" alt=""></div>
				</li>
				{foreach name="$item.goods" item="goods"}
				<li>
					<div class="tabb">
						<div class="left">
							<a href="{:url('Goods/show',['id'=>$goods['goods_id']])}"><img src="{$goods['goods_img_url']}" alt=""></a>
						</div>
						<div class="right">
							<b><a href="{:url('Goods/show',['id'=>$goods['goods_id']])}">{$goods['goods_title']}</a></b>
							<p>￥{$goods['goods_sell_price']} <em>x {$goods['goods_count']}</em></p>
						</div>
					</div>
				</li>
				{/foreach}
				<li>
					<div class="zhufff"><a href="{:url('Order/show',['id'=>$item['id']])}">订单详情</a>
					<a class="youfeif" href="javascript:;">邮费 {$item['cost']} 总计 {$item['cost']+$item['sum']}</a></div>
				</li>
			</ul>
			{/foreach}
			{else/}
			<div class="nofind"><img src="__INDEX__/images/nodd.png" alt=""><p>暂时没有订单</p></div>
			{/if}
		</div>
	</div>
</section>
{include file="include/nav"}
<script>
	$(".qrsh").click(function () {
        var orderId = $(this).data('id');
        $.ajax({
            url: "{:url('Order/confirm')}",
            type: "POST",
            data: {'orderId':orderId},
            dataType: "JSON",
            success: function(data) {
                if (data.code == 0) {
                    layer.msg(data.msg,{'icon':6,time:1000},function () {
						window.location.reload();
                    });
                } else {
                    layer.msg(data.msg,{'icon':5});
                }
            },
            error: function(){
                layer.msg("网络延迟，发送失败",{icon:5});
            }
        });
    });
    $('.ncdfbox .dfbox .shopul .shacc').click(function(){
        var that = this;
        var orderId = $(that).data('id');
        $.ajax({
            url: "{:url('Order/del')}",
            type: "POST",
            data: {'orderId':orderId},
            dataType: "JSON",
            success: function(data) {
                if (data.code == 0) {
                    $(that).parent().parent().remove();
                    layer.msg(data.msg,{'icon':6,time:1000});
                } else {
                    layer.msg(data.msg,{'icon':5});
                }
            },
            error: function(){
                layer.msg("网络延迟，发送失败",{icon:5});
            }
        });
    });
</script>
{/block}